﻿using System;
using System.Data;
using System.Windows.Forms;

namespace APP.HELPER.Utils.Language
{
    public static class MultiLanguages
    {
        public static string Language()
        {
            string result;
            try
            {
                DataSet dataSet = new DataSet();
                dataSet.ReadXml(Application.StartupPath + "\\Language\\Default.xml");
                result = dataSet.Tables[0].Rows[0][0].ToString();
            }
            catch
            {
                result = "vi-VN";
            }
            return result;
        }
        public static string GetString(string Table, string Key)
        {
            string result;
            try
            {
                DataSet dataSet = new DataSet();
                dataSet.ReadXml(string.Concat(new string[]
				{
					Application.StartupPath,
					"\\Language\\",
					MultiLanguages.Language(),
					"\\",
					MultiLanguages.Language(),
					".",
					Table,
					".xml"
				}));
                result = dataSet.Tables[0].Rows[0][Key].ToString();
            }
            catch
            {
                result = "";
            }
            return result;
        }
        public static string GetString(string Table, string Key, string Default)
        {
            string result;
            try
            {
                DataSet dataSet = new DataSet();
                dataSet.ReadXml(string.Concat(new string[]
				{
					Application.StartupPath,
					"\\Language\\",
					MultiLanguages.Language(),
					"\\",
					MultiLanguages.Language(),
					".",
					Table,
					".xml"
				}));
                result = dataSet.Tables[0].Rows[0][Key].ToString();
            }
            catch
            {
                result = Default;
            }
            return result;
        }
    }
}
